//package com.milk.service.cqrs;
//
//import java.util.HashMap;
//import java.util.LinkedHashMap;
//import java.util.Map;
//import java.util.concurrent.CountDownLatch;
//
//import org.reveno.atp.api.Reveno;
//import org.reveno.atp.api.dynamic.DynamicCommand;
//import org.reveno.atp.core.Engine;
//import org.reveno.atp.core.api.ViewsStorage;
//
//import com.alibaba.druid.sql.parser.LayoutCharacters;
//import com.milk.model.entity.admin.Admin;
//import com.milk.model.entity.admin.Admin.AdminView;
//
//public class RevenoDemo {
//	
//	private static Reveno reveno;
//	
//	private static long start;
//	
//	private static DynamicCommand addName;
//	
//	private static CountDownLatch latch = new CountDownLatch(100);
//	
//	public static void init(){
//		reveno = new Engine("C:\\Users\\vi\\Desktop\\cqrs");
//		
//		reveno.domain().viewMapper(Admin.class, AdminView.class, (id,e,r) -> new AdminView(id, e.name, e.username,e.password,e.administrator,e.roleId));
//	 
//		DynamicCommand createAdmin = reveno.domain().transaction("createAdmin", 
//				(t,c) -> c.repo().store(t.id(), new Admin(t.id(),t.arg("name"),t.arg("username"),t.arg("password"),t.bool("administrator"),t.longArg("roleId")))).uniqueIdFor(Admin.class).command();
//	
//		addName = reveno.domain().transaction("addName", (t,c) -> c.repo().remap(t.longArg("id"),Admin.class,(id,a) -> a.addName(t.arg("name")))).command();
//	}
//	
//	public static void main(String[] args) {
//		init();
//	
//		reveno.startup();
////		
////		//System.out.println(reveno.query().find(AdminView.class, 1).name);
////		
////		Map<String,Object> map = new HashMap<String,Object>();
////		map.put("name", "初始化");
////		map.put("username", "init");
////		map.put("password", "123456");
////		map.put("administrator", false);
////		map.put("roleId", 0L);
////		
////		long adminId = reveno.executeSync(createAdmin, map);
////		
////		System.out.println(adminId);
//		long start = System.currentTimeMillis();
////		
////		
////		for(int i=0;i<100;i++){
////			new MyThread(i).start();
////		}
////		
////		try {
////			latch.await();
////		} catch (InterruptedException e) {
////			// TODO Auto-generated catch block
////			e.printStackTrace();
////		}
//		
//		((ViewsStorage)reveno.query()).clearAll();
//		
//		
//		//System.out.println(reveno.query().find(AdminView.class, 1).name+"耗时："+(System.currentTimeMillis()-start));
//		
//		
//		reveno.shutdown();
//	}
//	
//	static class MyThread extends Thread{
//		private static int num;
//		public MyThread(int num){
//			this.num = num;
//		}
//		@Override
//		public void run() {
//			Map<String,Object> map = new HashMap<String,Object>();
//			map.put("id", 1L);
//			for(int i=1;i<=10000;i++){
//					map.put("name", "需整套"+(num*10000+i));
//					reveno.executeSync(addName,map);
//				}
//			latch.countDown();
//		}
//		
//	}
//
//}
